package com.neusoft.dibuy.ttc;


import java.util.Arrays;
import java.util.Scanner;

public class Shuzu1 {
    public static void main(String[] args) {
        int[] is = {1, 2, 3, 1, 2, 3, 5, 4, 1, 2, 3, 4, 5};
        for (int left = 0; left < is.length - 1; left++) {
            if (is[left] == 0) {
                continue;
            }
            for (int right = left + 1; right < is.length; right++) {
                if (is[right] == is[left]) {
                    is[right] = 0;
                }
            }
        }
        System.out.println(Arrays.toString(is));
    }

    public static void mainE(String[] args) {
        int[] is = {1, 1, 2, 2, 3, 3, 3, 4, 5, 6, 7, 7, 8};
        System.out.println(Arrays.toString(is));
        int left = 0;
        for (int right = 1; right < is.length; right++) {
            if (is[right] == is[left]) {
                is[right] = 0;
            } else {
                left = right;
            }
        }
        System.out.println(Arrays.toString(is));
    }

    public static void mainD(String[] args) {
        int[] is = {7, 9, 6, 2, 5, 1, 0, 3, 8, 4};
        int[] res = new int[is.length];
        for (int i = 0; i < is.length; i++) {
            res[is.length - 1 - i] = is[i];
        }
        System.out.println(Arrays.toString(res));
    }

    public static void mainc(String[] args) {
        int a[] = new int[5];
        int[] is = {23, 47, 89, 0, 7, 8, 9, 7, 897, 8, 902, 4, 3478, 9234, 5, 789, 789, 55, 07, 8, 904, 5};
        Arrays.sort(is);
        System.out.println(Arrays.toString(is));
    }

    public static void mainb(String[] args) {
        int[] is = {7, 9, 6, 2, 5, 1, 0, 3, 8, 4};
        Arrays.sort(is);
        System.out.println(Arrays.toString(is));
    }

    public static void maina(String[] args) {
        int[] is = {7, 9, 6, 2, 5, 1, 0, 3, 8, 4};
        int[] target = new int[is.length];
////        遍历数组
////        is[i]  --- >  target[i]
//        for (int i = 0; i < is.length; i++) {
//            target[i] = is[i];
//        }
//        System.out.println(Arrays.toString(target));
        System.arraycopy(is, 0, target, 0, is.length);
    }

    public static void main9(String[] args) {
        int[] is = {7, 9, 6, 2, 5, 1, 0, 3, 8, 4};
        boolean running = false;
        System.out.println(Arrays.toString(is));
        for (int j = 1; j < is.length; j++) {
            running = false;
            for (int i = 0; i < is.length - j; i++) {
                if (is[i] > is[i + 1]) {
                    running = true;
                    int temp = is[i];
                    is[i] = is[i + 1];
                    is[i + 1] = temp;
                }
            }
            System.out.println(Arrays.toString(is));
            if (!running) break;
        }
    }


    public static void main8(String[] args) {
        int index = 1;
        int[] is = {7, 9, 6, 2, 5, 1, 0, 3, 8, 4};
        for (int i = 0; i < is.length - index; i++) {
            if (is[i] > is[i + 1]) {
                int temp = is[i];
                is[i] = is[i + 1];
                is[i + 1] = temp;
            }
        }
        index++;
        System.out.println(Arrays.toString(is));
        for (int i = 0; i < is.length - index; i++) {
            if (is[i] > is[i + 1]) {
                int temp = is[i];
                is[i] = is[i + 1];
                is[i + 1] = temp;
            }
        }
        System.out.println(Arrays.toString(is));
        index++;
        System.out.println(Arrays.toString(is));
        for (int i = 0; i < is.length - index; i++) {
            if (is[i] > is[i + 1]) {
                int temp = is[i];
                is[i] = is[i + 1];
                is[i + 1] = temp;
            }
        }
        System.out.println(Arrays.toString(is));
        index++;
        System.out.println(Arrays.toString(is));
        for (int i = 0; i < is.length - index; i++) {
            if (is[i] > is[i + 1]) {
                int temp = is[i];
                is[i] = is[i + 1];
                is[i + 1] = temp;
            }
        }
        System.out.println(Arrays.toString(is));
        index++;
        System.out.println(Arrays.toString(is));
        for (int i = 0; i < is.length - index; i++) {
            if (is[i] > is[i + 1]) {
                int temp = is[i];
                is[i] = is[i + 1];
                is[i + 1] = temp;
            }
        }
        System.out.println(Arrays.toString(is));
        index++;
        System.out.println(Arrays.toString(is));
        for (int i = 0; i < is.length - index; i++) {
            if (is[i] > is[i + 1]) {
                int temp = is[i];
                is[i] = is[i + 1];
                is[i + 1] = temp;
            }
        }
        System.out.println(Arrays.toString(is));
        index++;
        System.out.println(Arrays.toString(is));
        for (int i = 0; i < is.length - index; i++) {
            if (is[i] > is[i + 1]) {
                int temp = is[i];
                is[i] = is[i + 1];
                is[i + 1] = temp;
            }
        }
        System.out.println(Arrays.toString(is));


    }

    public static void main7(String[] args) {
        int[] is = {7, 9, 6, 2, 5, 1, 0, 3, 8, 4};
//      第一趟：   最大数放在最右侧 746251038          9
//         沉石                    74625103          89

        int max = is[0];
        int maxIndex = 0;
        int L = is.length;
        int ll = 0;
        for (int i = 1; i < L - ll; i++) {
            if (is[i] > max) {
                max = is[i];
                maxIndex = i;
            }
        }
        int temp = is[maxIndex];
        is[maxIndex] = is[L - ll - 1];
        is[L - ll - 1] = temp;
        System.out.println(Arrays.toString(is));
        ll++;
        max = is[0];
        maxIndex = 0;
        for (int i = 1; i < L - ll; i++) {
            if (is[i] > max) {
                max = is[i];
                maxIndex = i;
            }
        }
        temp = is[maxIndex];
        is[maxIndex] = is[L - ll - 1];
        is[L - ll - 1] = temp;
        System.out.println(Arrays.toString(is));

        ll++;
        max = is[0];
        maxIndex = 0;
        for (int i = 1; i < L - ll; i++) {
            if (is[i] > max) {
                max = is[i];
                maxIndex = i;
            }
        }
        temp = is[maxIndex];
        is[maxIndex] = is[L - ll - 1];
        is[L - ll - 1] = temp;
        System.out.println(Arrays.toString(is));

        ll++;
        max = is[0];
        maxIndex = 0;
        for (int i = 1; i < L - ll; i++) {
            if (is[i] > max) {
                max = is[i];
                maxIndex = i;
            }
        }
        temp = is[maxIndex];
        is[maxIndex] = is[L - ll - 1];
        is[L - ll - 1] = temp;
        System.out.println(Arrays.toString(is));
        ll++;
        max = is[0];
        maxIndex = 0;
        for (int i = 1; i < L - ll; i++) {
            if (is[i] > max) {
                max = is[i];
                maxIndex = i;
            }
        }
        temp = is[maxIndex];
        is[maxIndex] = is[L - ll - 1];
        is[L - ll - 1] = temp;
        System.out.println(Arrays.toString(is));
        ll++;
        max = is[0];
        maxIndex = 0;
        for (int i = 1; i < L - ll; i++) {
            if (is[i] > max) {
                max = is[i];
                maxIndex = i;
            }
        }
        temp = is[maxIndex];
        is[maxIndex] = is[L - ll - 1];
        is[L - ll - 1] = temp;
        System.out.println(Arrays.toString(is));
        ll++;
        max = is[0];
        maxIndex = 0;
        for (int i = 1; i < L - ll; i++) {
            if (is[i] > max) {
                max = is[i];
                maxIndex = i;
            }
        }
        temp = is[maxIndex];
        is[maxIndex] = is[L - ll - 1];
        is[L - ll - 1] = temp;
        System.out.println(Arrays.toString(is));
        ll++;
        max = is[0];
        maxIndex = 0;
        for (int i = 1; i < L - ll; i++) {
            if (is[i] > max) {
                max = is[i];
                maxIndex = i;
            }
        }
        temp = is[maxIndex];
        is[maxIndex] = is[L - ll - 1];
        is[L - ll - 1] = temp;
        System.out.println(Arrays.toString(is));


    }

    public static void main6(String[] args) {
//        递增有序的
//          L            找到            找不到
//        有序            L/2             L/2
//        无序            L/2             L
        int[] is = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
        double d = 3.5;
        int index = -1;
        for (int i = 0; i < is.length; i++) {
            if (is[i] > d) {
                break;
            }
            if (is[i] == d) {
                index = i;
                break;
            }
        }
        System.out.println(index);
    }

    public static void main5(String[] args) {
//        矛盾论
//        index ; 8
//        -1;
        int[] is = {7, 9, 6, 2, 5, 1, 0, 3, 8, 4};
        System.out.println(" 被查找的数 ---- > N:  ");
//        从键盘获得输入；
        Scanner scanner = new Scanner(System.in);
        int index = -1;
//        把输入的数据转换为整数
        int n = scanner.nextInt();
        System.out.println(n);
//        n  = 8;
//        遍历
        for (int i = 0; i < is.length; i++) {
            if (is[i] == n) {
                index = i;
                break;
            }
        }
        System.out.println(index);

//         == n？
//        if === n   i---->index; break;


    }


    public static void main4(String[] args) {
        int[] is = {7, 9, 6, 2, 5, 1, 0, 3, 8, 4};
        int res = is[0];
        for (int index = 1; index < is.length; index++) {
            res += is[index];
        }
        System.out.println(res);
    }

    public static void main3(String[] args) {
        int[] is = {7, 9, 6, 2, 5, 1, 0, 3, 8, 4};
        int res = is[0];
        int index = 1;
        for (int i = 100; i < 109; i++) {
            res = res + is[index];
            index++;
        }
        System.out.println(res);
    }

    public static void main2(String[] args) {
        int[] is = {7, 9, 6, 2, 5, 1, 0, 3, 8, 4};
        int min = is[is.length - 1];
        int min_index = is.length - 1;

        for (int i = is.length - 2; i >= 0; i--) {
            if (min > is[i]) {
                min = is[i];
                min_index = i;
            }

        }
    }

    public static void main1(String[] args) {
//        数组
        int[] is = {7, 9, 6, 2, 5, 1, 0, 3, 8, 4};
//        假定  1  -- 》  max
        int max = is[0];
//        遍历
        for (int index = 1; index < is.length; index++) {
            if (max < is[index]) {
                max = is[index];
            }
        }
//        Data 》 max   Data--->  max
        System.out.println("Shuzu1.main ---- > " + max);
    }
}
